package com.qust.edu.aliyun.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qust.edu.aliyun.dto.OrdersDto;
import com.qust.edu.aliyun.mapper.BuyerMapper;
import com.qust.edu.aliyun.mapper.OrdersMapper;
import com.qust.edu.aliyun.pojo.Buyer;
import com.qust.edu.aliyun.pojo.Orders;
import com.qust.edu.aliyun.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * projectName: ALIYUN
 *
 * @author: 姜龙
 * time: 2021/9/28 14:02
 * description:
 */
@Service
public class OrdersServiceImpl implements OrdersService {


    @Autowired
    private OrdersMapper ordersMapper;

    @Autowired
    private BuyerMapper buyerMapper;



    /**
     * 按订单交易状态查询业务
     *
     * @param ordersDto
     * @return
     */
    @Override
    public Object getOrderStatus(OrdersDto ordersDto) {


        //获取数据
        List<Orders> orders = ordersMapper.queryOrders(ordersDto);

        //数据封装
        Map data = new HashMap();
        data.put("code",001);
        data.put("Order",orders);

        System.out.println("data = " + data);
        return data;
    }

    @Override
    public Object getOrderBuyer(OrdersDto ordersDto) {

        //查询条件
        System.out.println("orders = " + ordersDto.getBuyer_id());
        QueryWrapper<Buyer> queryWrapper = new QueryWrapper();
        queryWrapper.eq("buyer_id",ordersDto.getBuyer_id());
        //获取数据
        List<Buyer> buyers = buyerMapper.selectList(queryWrapper);

        //数据封装
        Map data = new HashMap();
        data.put("code",001);
        data.put("Buyer",buyers);
        System.out.println("data = " + data);
        return data;

    }
}
